package com.quick.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RedissonConfig {

	private final static Logger log = LoggerFactory.getLogger(RedissonConfig.class);
	
@Autowired
private QuickLockProperties quickLockProperties;
 	@Bean
	public RedissonClient redissonClient() {
		Config config = new Config();
		log.info("RedissonConfig:{}",quickLockProperties);
		config.useSingleServer().setPassword(quickLockProperties.getPassword())
				.setDatabase(quickLockProperties.getDatabase())
				.setAddress(quickLockProperties.getProtocol()+quickLockProperties.getHost()+":"+quickLockProperties.getPort())
		;
		return Redisson.create(config);
 }
}
